package org.phone.manager.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "product_type", catalog = "phonemanager")
public class ProductType extends EntityParent {

	private String typeName;
	private Integer order;
	private String description;
	private Set<Product> products;
	private ProductType parentType;
	private Set<ProductType> childrenType;

	public ProductType() {
	}

	@Column(name = "type_name", length = 45)
	public String getTypeName() {
		return this.typeName;
	}

	public void setTypeName(String firstName) {
		this.typeName = firstName;
	}

	@Column(name = "order_id")
	public Integer getOrder() {
		return this.order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	@Column(name = "description", length = 20)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "productType")
	public Set<Product> getProducts() {
		return this.products;
	}

	public void setProducts(Set<Product> products) {
		this.products = products;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "parent_id")
	public ProductType getParentType() {
		return this.parentType;
	}

	public void setParentType(ProductType fatherType) {
		this.parentType = fatherType;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "parentType")
	public Set<ProductType> getChildrenType() {
		return childrenType;
	}

	public void setChildrenType(Set<ProductType> childrenType) {
		this.childrenType = childrenType;
	}

}
